$(function () {
	var page = 1;
    if (localStorage.getItem("page3")) {
    	page = localStorage.getItem("page3");
        localStorage.removeItem("page3");
	} 
    
    $("#jqGrid").jqGrid({
        url: baseURL + 'bdbusiness/bbrecommendresult/list',
        datatype: "json",
        page:page,
        postData: {
            'id': url('id')
        },
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true,hidden: true },
			{ label: '企业名称', name: 'entname', index: 'entname', width: 80, 
                formatter: function (value, options, row) {
	                return '<a href="javascript:void(0);" onclick="vm.showentinfo(\''+value+'\');">'+value+'</a>';
//	                return '<a href="cregisterinfo.html?entname='+value+'">'+value+'</a>';
                }
			}			
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		bBRecommendResult: {}
	},
	methods: {
		query: function () {
            $("#jqGrid").setGridParam({'page': 1});
			vm.reload();
		},
		getInfo: function(id){
			$.get(baseURL + "bdbusiness/bbrecommendresult/info/"+id, function(r){
                vm.bBRecommendResult = r.bBRecommendResult;
            });
		},
		showentinfo: function (value) {
			localStorage.setItem("page3", $('#jqGrid').getGridParam('page'));
		    window.location.href = 'cregisterinfo.html?entname='+value;
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{
				postData: {'id': url('id')}, 
                page:page
            }).trigger("reloadGrid");
		}
	}
});
